package cn.kailangtu.commonevents.eventEntity;

import static android.util.Config.DEBUG;

import java.util.Random;

public class TotalMainDataChangedEvent {
    private int[] voltageValues;
    private int[] electricValues;
    private int[] electricValueA,electricValueB,electricValueC;
    private int maxValueVoltage,maxValueElectric;
    private int minValueVoltage,minValueElectric;


    public TotalMainDataChangedEvent(int[] voltageValues,int[] electricValues,int[] electricValueA,int[] electricValueB,int[] electricValueC) {
        this.voltageValues = voltageValues;
        this.electricValues = electricValues;
        this.electricValueA = electricValueA;
        this.electricValueB = electricValueB;
        this.electricValueC = electricValueC;


    }

    private void resetValue(int[] source,int maxValue)
    {
        Random r = new Random();
        for(int i =0;i< source.length;i++)
        {
            source[i] = 100+ r.nextInt(maxValue);
        }
    }


    public int[] getVoltageValues() {
        return voltageValues;
    }

    public int[] getElectricValues() {
        return electricValues;
    }


    public int getMaxElectricValue()
    {
        maxValueElectric = Integer.MIN_VALUE;
        for(int value: electricValueA)
        {
            if(value > maxValueElectric)
            {
                maxValueElectric = value;
            }
        }
        for(int value: electricValueB)
        {
            if(value > maxValueElectric)
            {
                maxValueElectric = value;
            }
        }
        for(int value: electricValueC)
        {
            if(value > maxValueElectric)
            {
                maxValueElectric = value;
            }
        }
        return maxValueElectric;
    }

    public int getMinElectricValue(){
        minValueElectric = Integer.MAX_VALUE;
        for(int value: electricValueA)
        {
            if(value < minValueElectric)
            {
                minValueElectric = value;
            }
        }
        for(int value: electricValueB)
        {
            if(value > minValueElectric)
            {
                minValueElectric = value;
            }
        }
        for(int value: electricValueC)
        {
            if(value > minValueElectric)
            {
                minValueElectric = value;
            }
        }
        return minValueElectric;
    }


    public int getMaxVoltageValue()
    {
        maxValueVoltage = Integer.MIN_VALUE;
        for(int value : voltageValues)
        {
            if(value > maxValueVoltage)
            {
                maxValueVoltage = value;
            }
        }
        return maxValueVoltage;
    }

    public int getMinVoltageValue()
    {
        minValueVoltage = Integer.MAX_VALUE;
        for(int value : voltageValues)
        {
            if(value < minValueVoltage)
            {
                minValueVoltage = value;
            }
        }

        return minValueVoltage;
    }

    public int[] getElectricValueA() {
        return electricValueA;
    }

    public int[] getElectricValueB() {
        return electricValueB;
    }

    public int[] getElectricValueC() {
        return electricValueC;
    }
}
